import Vue from "vue";
import VueRouter from "vue-router";
import Index from "../views/Index.vue";
import Login from "../views/Login.vue";
import Chat from '../views/Chat.vue'
import File from '../views/File.vue'
import Friend from '../views/Friend.vue'

Vue.use(VueRouter);

const routes = [{
    path: '/',
    redirect: '/index',
  },
  {
    path: "/login",
    name: "login",
    component: Login,
  },
  {
    path: "/index",
    name: "index",
    component: Index,
    redirect: '/chat',
    children: [
      { path: '/chat', name: 'chat', component: Chat },
      { path: '/friend', name: 'friend', component: Friend },
      { path: '/file', name: 'file', component: File },
    ]
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

router.beforeEach((to, from, next) => {
  // console.log(to);
  next()
})

export default router;